/*
 * @Author: YNT 2501512800@qq.com
 * @Date: 2022-06-19 15:06:46
 * @LastEditors: YNT 2501512800@qq.com
 * @LastEditTime: 2022-09-08 00:46:45
 * @FilePath: \智慧社区的副本\src\api\modules\integral.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
export default class {
  //#region 规则管理
  getIntegralRuleList(params) {
    return this.request({
      url: "admin/v1/balance/type/list",
      method: "GET",
      params,
    });
  }
  addIntegralRule(data) {
    return this.request({
      url: `/api/admin/score_conf/`,
      method: "POST",
      data,
    });
  }
  editIntegralRule(id, data) {
    return this.request({
      url: `/admin/v1/balance/type?id=${id}`,
      method: "POST",
      data,
    });
  }
  delIntegralRule(id) {
    return this.request({
      url: `/api/admin/score_conf/${id}/`,
      method: "DELETE",
    });
  }
  //#endregion

  // 积分变化
  getIntegralChangeList(params) {
    return this.request({
      url: "/admin/v1/balance/change_list",
      method: "GET",
      params,
    });
  }

  // 积分分类
  getIntegralGoodsType(params) {
    return this.request({
      url: `/api/admin/shop_category/`,
      method: "GET",
      params,
    });
  }

  addIntegralGoodsType(data) {
    return this.request({
      url: `/api/admin/shop_category/`,
      method: "POST",
      data,
    });
  }

  editIntegralGoodsType(id, data) {
    return this.request({
      url: `/api/admin/shop_category/${id}/`,
      method: "PUT",
      data,
    });
  }

  delIntegralGoodsType(id) {
    return this.request({
      url: `/api/admin/shop_category/${id}/`,
      method: "DELETE",
    });
  }

  //#region 商品管理

  // 商品分类列表
  getIntegralGoodType(params) {
    return this.request({
      url: "/admin/v1/goods/type",
      method: "GET",
      params,
    });
  }

  addIntegralGoodType(data) {
    return this.request({
      url: `/admin/v1/goods/type`,
      method: "PUT",
      data,
    });
  }

  editIntegralGoodType(id, data) {
    return this.request({
      url: `/admin/v1/goods/type?id=${id}`,
      method: "POST",
      data,
    });
  }

  delIntegralGoodType(id) {
    return this.request({
      url: `/admin/v1/goods/type?id=${id}`,
      method: "DELETE",
    });
  }

  setIntegralGoodType(id, data) {
    return this.request({
      url: `/admin/v1/goods/type/seq?id=${id}`,
      method: "POST",
      data,
    });
  }

  getIntegralGoodsList(params) {
    return this.request({
      url: "/admin/v1/goods/list",
      method: "GET",
      params,
    });
  }
  addIntegralGoods(data) {
    return this.request({
      url: `/admin/v1/goods`,
      method: "PUT",
      data,
    });
  }
  editIntegralGoods(id, data) {
    return this.request({
      url: `/admin/v1/goods?id=${id}`,
      method: "POST",
      data,
    });
  }
  delIntegralGoods(id) {
    return this.request({
      url: `/admin/v1/goods?id=${id}`,
      method: "DELETE",
    });
  }
  //#endregion
 
  getIntegralOrderList(params) {
    return this.request({
      url: "/admin/v1/goods_order/list?status=0",
      method: "GET",
      params,
    });
  }
  // 核销
  setIntegralOrderStatus(id, data) {
    return this.request({
      url: `/api/admin/shop_record/${id}/`,
      method: "PUT",
      data,
    });
  }
  //#endregion
}
